﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KOL.aspx.cs" Inherits="OgilvyOne.Sharan.Web.KOL" %>
<%@ Register TagPrefix="cc1" Namespace="ECCIT.Web.UI.WebControls" Assembly="ECCIT.Web" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title></title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<script language="javascript">
		<!--
		    function InitializePage() {
		        DataGrid_Gridcontrol1.DataSource = GetData();
		        DataGrid_Gridcontrol1.DataBind();
		    }

		    function GetData() {
		        //var pagingParam = DataGrid_Gridcontrol1.GetPagingParameter();
		        var units = WeiboUserBLL.GetAllWeiboUsers().value;
		        DataGrid_Gridcontrol1.VirtualItemCount = units.length;
		        return units;
		    }

		    function DataGrid_OnItemDataBind(item) {
		        var modelInfo = item.DataItem;
		        if (modelInfo != null) {
		            var id = modelInfo.ID;
//		            var type = modelInfo.Type;
//		            var status = modelInfo.Status;

		            modelInfo.Operation = "<a href='javascript:Delete(\"" + id + "\")'>删除</a>";
//		            modelInfo.TypeText = Unit.GetTypeText(type).value;
//		            modelInfo.StatusText = Unit.GetStatusText(status).value;
		        }
		    }

		    function LoadUnit(guid) {
		        var resp = Unit.GetUnit(guid);
		        var unitInfo = null;
		        if (resp.error) {
		            alert(resp.error.Message);
		        }
		        else {
		            unitInfo = resp.value;
		        }

		        return unitInfo;
		    }

		    function AddNew() {
		        
		    }

		    function CheckForm() {
		        var model = getModelFromControl();

//		        if (!CheckEmpty_Msg(model.LoginName, "KOL微博账号"))
//		            return false;

//		        if (!CheckEmpty_Msg(model.WeiboUserID, "KOL微博ID"))
//		            return false;

		        return true;
		    }

		    function Save() {
		        if (CheckForm()) {
		            var unitInfo = GetUnitInfoFromControl();
		            var resp = KOL.Save(unitInfo);
		            if (resp.error) {
		                alert("保存KOL信息出现错误，错误信息：" + resp.error.Message);
		            }
		            else {
		                var result = resp.value;
		                alert("保存KOL信息成功！");
		                InitializePage();
		                //window.parent.frames[0].location.href = "UnitTree.aspx";
		            }
		        }
		    }

		    function Delete(id) {
		        if (confirm("您确定要删除所选择的KOL信息吗？")) {
		            //alert(selectedGuids);
		            var resp = WeiboUserBLL.Delete(parseInt(id));
		            var ajaxResp = new AjaxResponse(resp);
		            if (ajaxResp.Handle()) {
		                var result = ajaxResp.Value;
		                if (result) {
		                    alert("删除成功!");
		                    InitializePage();
		                }
		                else {
		                    alert("删除失败!");
		                }
		            }
		            else {
		                alert("删除失败,错误信息:" + ajaxResp.Error);
		            }
		        }
		    }

//		    function ParseUnitInfo(guid) {
//		        var unitInfo = LoadUnit(guid);
//		        if (unitInfo != null) {
//		            document.getElementById("hdnUnitGuid").value = unitInfo.Guid;
//		            document.getElementById("txtUnitName").value = unitInfo.Name;
//		            document.getElementById("txtUnitCode").value = unitInfo.Code;
//		            document.getElementById("rdoType" + unitInfo.Type).checked = true;
//		            document.getElementById("rdoStatus" + unitInfo.Status).checked = true;
//		            document.getElementById("txtUnitDesc").value = unitInfo.Description;
//		            document.getElementById("txtShortName").value = unitInfo.ShortName;
//		            document.getElementById("txtLegalPerson").value = unitInfo.LegalPerson;
//		            document.getElementById("txtHeadMan").value = unitInfo.HeadMan;
//		            document.getElementById("txtTel").value = unitInfo.Tel;
//		            document.getElementById("txtFax").value = unitInfo.Fax;
//		            document.getElementById("txtAddress").value = unitInfo.Address;
//		            document.getElementById("txtZipCode").value = unitInfo.ZipCode;
//		            document.getElementById("txtBank").value = unitInfo.Bank;
//		            document.getElementById("txtBankAccount").value = unitInfo.BankAccount;
//		        }
//		    }

		    function getModelFromControl() {
		        var loginName = document.getElementById("txtWeiboName").value;
		        var weiboUserID = document.getElementById("txtWeiboID").value;
		        var age = document.getElementById("txtAge").value;
		        var job = document.getElementById("txtJob").value;
		        var hobby = document.getElementById("txtHobby").value;

		        var model = {
		            "LoginName": loginName,
		            "WeiboUserID": weiboUserID,
		            "Age": age,
		            "Job": job,
		            "Hobby": hobby
		        }

		        return model;
		    }

		    function GetUnitInfoFromControl() {
		        var model = getModelFromControl();

		        var unitInfo = "<ModelInfo Type=\"\">";
		        unitInfo += "<Properties>";
		        unitInfo += "<Property Name=\"LoginName\"><![CDATA[" + model.LoginName + "]]></Property>";
		        unitInfo += "<Property Name=\"WeiboUserID\"><![CDATA[" + model.WeiboUserID + "]]></Property>";
		        unitInfo += "<Property Name=\"Age\"><![CDATA[" + model.Age + "]]></Property>";
		        unitInfo += "<Property Name=\"Hobby\"><![CDATA[" + model.Hobby + "]]></Property>";
		        unitInfo += "<Property Name=\"Job\"><![CDATA[" + model.Job + "]]></Property>";
		        unitInfo += "</Properties>";
		        unitInfo += "</ModelInfo>";
		        return unitInfo;
		    }
		//-->
		</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<table class="tbtoolbar" cellSpacing="0" cellPadding="0" align="center" border="0">
				<tr>
					<td align="left">
						<div class="tbSeparator"></div>
					</td>
					<td width="100%">&nbsp;</td>
					<td align="left">
						<div class="tbSeparator"></div>
					</td>
				</tr>
			</table>
			<table class="tableborder" cellspacing="0" cellpadding="0" width="98%" align="center" border="0">
				<tr>
					<td class="tableboder" height="100%">
						<cc1:GridControl id="Gridcontrol1" runat="server" Width="98%" PageSize="15" AllowPaging="false" bordercolor="white"
							HeaderClass="titlemedium" SelectedItemClass="row" AlternatingItemClass="row3" ItemClass="row1"
							FooterClass="pformstrip" PagerClass="darkrow2" ItemDataBound="DataGrid_OnItemDataBind" GetData="GetData"
							AutoGenerateRows="true" ShowExpandRow="false" Height="106px" Scrolling="no" ScrollingMode="manual"
							SortExpression="" SortOrder="ASC" ShowFooter="false" ShowCheckBoxColumn=false
							rules="all" border="1" style="border-color:White;border-width:1px;border-style:solid;width:100%;border-collapse:collapse;">
							<Columns>
                                <Column Name="LoginName" HeaderText="KOL微博账号" SortExpression="" Width="15%"></Column>
								<Column Name="WeiboUserID" HeaderText="KOL微博ID" SortExpression="" Width="15%"></Column>
								<Column Name="Age" HeaderText="年龄" SortExpression="" Width="10%"></Column>
								<Column name="Job" headertext="职业" SortExpression="" Width="20%"></Column>
								<Column Name="Hobby" HeaderText="爱好" SortExpression="" Width="30%"></Column>
                                <Column Name="Operation" HeaderText="操作" width="5%"></Column>
							</Columns>
						</cc1:GridControl>
					</td>
				</tr>
			</table>
			<table class="tbtoolbar" style="margin-top:8px" cellSpacing="0" cellPadding="0" align="center" border="0">
				<tr>
					<td align="left">
						<div class="tbSeparator"></div>
					</td>
                    <td align="right">
						<div onmouseup="javascript:domouseup('tbBack');" class="tbButton" onmousedown="javascript:domousedown('tbBack');"
							id="tbBack" onmouseover="javascript:domouseover('tbBack');" title="新增" onmouseout="javascript:domouseout('tbBack');"
							align="center"><nobr>
								<a style="cursor:hand" onclick="javascript:AddNew()" id="hrefAdd" Class="linktext"><IMG src="images/toolbar/new.gif" align="middle" border="0">新增</a>
							</nobr>
						</div>
					</td>
					<td align="left">
						<div onmouseup="javascript:LKPDUOA5_domouseup('tbSave');" class="tbButton" onmousedown="javascript:LKPDUOA5_domousedown('tbSave');"
							id="tbSave" onmouseover="javascript:LKPDUOA5_domouseover('tbSave');" title="点击保存信息"
							onmouseout="javascript:LKPDUOA5_domouseout('tbSave');" align="center"><nobr>
								<a style="cursor:hand" onclick="javascript:Save()" id="hrefSave" Class="linktext"><IMG src="images/toolbar/save.gif" align="middle" border="0">保存</a>
						</nobr></div>
					</td>
					<td width="100%">&nbsp;</td>
					<td align="left">
						<div class="tbSeparatorEnd"></div>
					</td>
				</tr>
			</table>
				<table class="tableborder" id="Table5" style="MARGIN: 0px; WIDTH: 98%" cellSpacing="0"
					cellPadding="0" align="center" border="0">
					<tr>
						<td vAlign="top" width="100%">
							<table style="MARGIN: 0px; WIDTH: 100%" cellSpacing="0" cellPadding="0" align="center"
								border="0">
                                <tr class="InputFrameLine">
									<td class="pformleft" align="left" width="100px"><nobr>KOL微博账号</nobr></td>
									<td class="pformrightline" width="80%">
										<input type=text id="txtWeiboName" maxlength=50 style="width:100%" class=input>
									</td>
								</tr>
								<tr class="InputFrameLine">
									<td class="pformleft" align="left" width="100px"><nobr>KOL微博ID</nobr></td>
									<td class="pformrightline" width="80%">
										<input type=text id="txtWeiboID" maxlength=20 style="width:100%" class=input>
									</td>
								</tr>
								<tr class="InputFrameLine">
									<td class="pformleft" align="left" width="100px"><nobr>年龄</nobr></td>
									<td class="pformrightline" width="80%">
										<input type=text id="txtAge" maxlength=4 style="width:100%" class=input>
									</td>
								</tr>
								<tr class="InputFrameLine">
									<td class="pformleft" align="left" width="100px"><nobr>职业</nobr></td>
									<td class="pformrightline" width="80%">
										<input type=text id="txtJob" maxlength=50 style="width:100%" class=input>
									</td>
								</tr>
								<tr class="InputFrameLine">
									<td class="pformleft" align="left" >爱好</td>
									<td class="pformright" colspan="3">
										<textarea class="inputarea" id="txtHobby" style="WIDTH:100%;height:100px" Rows="9"></textarea>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
		</form>
		<script language="javascript">
		<!--
		    InitializePage();
		//-->
		</script>
	</body>
</HTML>
